package hashtables.Entries;

/**
 * An entry in the list of a bucket.
 * At the moment there is only a value which is also the key.
 * If you want to seperate the key and the value, just rename "value" to "key"
 * and add another value.
 * @author Konstantin, Jan
 */
public class Entry
{
    private int _value;

    /**
     * Creates an entry with a value
     * @param value Value of the entry
     */
    public Entry(int value)
    {
        _value = value;
    }

    /**
     * Gets the value
     * @return The value
     */
    public int getValue()
    {
        return _value;
    }

    /**
     * Sets the value
     * @param value The value to set
     */
    public void setValue(int value)
    {
        _value = value;
    }

    /**
     * Overrides the hashCode
     * @return The hash
     */
    @Override public int hashCode()
    {
        return _value;
    }
    
    /**
     * Overrides the equals
     * @return true if they are equal
     */
    @Override public boolean equals(Object that)
    {
        // Comparing with itself
        if (this == that)
        {
            return true;
        }
        
        // Not an Entry
        if (!(that instanceof Entry))
        {
            return false;
        }
    
        // Compare the values
        return _value == ((Entry)that).getValue();
    }
}